/*
 * ojm_model.h
 *
 * Created on: 2024-06-14
 *     Author: van
 */

#ifndef _SRC_SERVICE_SITE_LIB_OJM_H_
#define _SRC_SERVICE_SITE_LIB_OJM_H_

#include <string>
#include <vector>
#include <array>

#include "nlohmann/json.hpp"

using namespace std;

using json = nlohmann::json;

namespace servicesite {

class MessageSubscriberSiteHandle;

class ServiceDebugResponseMessageSubscriberListItemSiteHandleListItem {
public:
    string ip;
    int port;
    string mac;
    string site_id;
    int retry_count;
    uint32_t failed_ts;
    uint32_t stats_cnt_send;
    vector<uint32_t> stats_cnt_drop;

    json to_json(void);
    int from_json(json json_data);
    void from_handle(const MessageSubscriberSiteHandle& data);
};

class ServiceDebugResponseMessageSubscriberListItem {
public:
    string message_id;
    vector<ServiceDebugResponseMessageSubscriberListItemSiteHandleListItem> site_handle_list;
    vector<string> site_handle_list_dbg;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceGetMessageListResponseMessageListItem {
public:
    string message_id;
    string name;
    string summary;
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceAnyGetMessageListRequest {
public:
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceAnyGetMessageListResponse {
public:
    vector<ServiceGetMessageListResponseMessageListItem> message_list;
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceAnySubscribeMessageRequest {
public:
    vector<string> message_list;
    string ip;
    int port;
    string mac;
    string site_id;
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceAnySubscribeMessageResponse {
public:
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceAnyUnsubscribeMessageRequest {
public:
    vector<string> message_list;
    int port;
    string mac;
    string site_id;
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceAnyUnsubscribeMessageResponse {
public:
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceSiteQuerySitePingRequest {
public:
    string site_id;
    int port;
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceSiteQuerySitePingResponse {
public:
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceSiteQuerySiteRegisterRequest {
public:
    string site_id;
    string summary;
    int port;
    json to_json(void);
    int from_json(json json_data);
};

class AccessServiceSiteQuerySiteRegisterResponse {
public:
    json to_json(void);
    int from_json(json json_data);
};

class ServiceDebugRequest {
public:
    json to_json(void);
    int from_json(json json_data);
};

class ServiceDebugResponse {
public:
    string lib_ver;
    vector<ServiceDebugResponseMessageSubscriberListItem> message_subscriber_list;
    vector<ServiceDebugResponseMessageSubscriberListItemSiteHandleListItem> message_subscriber_site_handle_list;
    //TODO: 记录下来自接收方的错误统计
    json to_json(void);
    int from_json(json json_data);
};

class ServiceGetMessageListRequest {
public:
    json to_json(void);
    int from_json(json json_data);
};

class ServiceGetMessageListResponse {
public:
    vector<ServiceGetMessageListResponseMessageListItem> message_list;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceGetServiceListRequest {
public:
    json to_json(void);
    int from_json(json json_data);
};

class ServiceGetServiceListResponse {
public:
    vector<string> service_list;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceSiteLibServiceMessage {
public:
    string message_id;
    string from;
    json content;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceSiteLibServiceRequest {
public:
    string service_id;
    string to;
    json request;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceSiteLibServiceResponse {
public:
    int code;
    string error;
    json response;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceSubscribeMessageRequest {
public:
    vector<string> message_list;
    string ip;
    int port;
    string mac;
    string site_id;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceSubscribeMessageResponse {
public:
    json to_json(void);
    int from_json(json json_data);
};

class ServiceUnsubscribeMessageRequest {
public:
    vector<string> message_list;
    int port;
    string mac;
    string site_id;
    json to_json(void);
    int from_json(json json_data);
};

class ServiceUnsubscribeMessageResponse {
public:
    json to_json(void);
    int from_json(json json_data);
};

}
#endif /* _SRC_SERVICE_SITE_LIB_OJM_H_ */
